from django.db import models
from django.contrib.auth.models import AbstractUser
# Create your models here.
class User(AbstractUser):
    """自定义用户模型类"""
    mobile = models.CharField(max_length=11, unique=True, verbose_name='手机号')
    user_img = models.CharField(max_length=255, null=True, verbose_name='个人头像')
    gender = models.CharField(max_length=1, null=True, verbose_name='性别')
    birth_date = models.DateField(null=True, verbose_name='出生日期')
    user_desc = models.CharField(max_length=255, null=True, verbose_name='个人介绍')


    class Meta:
        db_table = 'tb_users'
        verbose_name = '用户'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.username

class PlayList_Follow(models.Model):
    """用户创建和关注的歌单"""

    users = models.ForeignKey(User, on_delete=models.CASCADE, related_name='users', null=True,verbose_name='用户')
    playlist_id = models.CharField(max_length=30, null=True, verbose_name='歌单id')
    playlist_name = models.CharField(max_length=255, null=True, verbose_name='歌单名字')
    playlist_pic = models.CharField(max_length=255, null=True, verbose_name='歌单图片')
    playlist_song_count = models.CharField(max_length=255, null=True, default=0,verbose_name='歌单歌曲量')
    playlist_play_count = models.CharField(max_length=255, null=True, default=0,verbose_name='歌单播放量')
    is_deleted = models.BooleanField(default=False, verbose_name='逻辑删除歌单')

    class Meta:
        db_table = 'tb_playlist_follow'
        verbose_name = '关注歌单'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.playlist_id


class Album_Follow(models.Model):
    """用户关注的专辑"""

    users = models.ForeignKey(User, on_delete=models.CASCADE, related_name='user', null=True,verbose_name='用户')
    album_id = models.CharField(max_length=30, null=True, verbose_name='专辑id')
    album_name = models.CharField(max_length=255, null=True, verbose_name='专辑名字')
    album_pic = models.CharField(max_length=255, null=True, verbose_name='专辑图片')
    album_song_count = models.CharField(max_length=255, null=True, default=0,verbose_name='专辑歌曲量')
    singer_name = models.CharField(max_length=255, null=True,verbose_name='歌手名字')
    singer_id = models.CharField(max_length=255, null=True,verbose_name='歌手id')
    issue_time = models.CharField(max_length=255, null=True, default=0,verbose_name='发行时间')


    class Meta:
        db_table = 'tb_album_follow'
        verbose_name = '关注专辑'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.album_id